package com.cyzy.educationalai.config;

import com.cyzy.educationalai.chatMemory.RedisChatMemory;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zxw
 * @create 2025-05-17 下午4:35
 */
@Configuration
public class ChatConfig {
    @Bean
    public ChatClient chatClient(ChatModel chatModel, RedisChatMemory redisChatMemory) {
        return ChatClient.builder(chatModel)
                .defaultAdvisors(
                        new SimpleLoggerAdvisor(),
                        MessageChatMemoryAdvisor.builder(redisChatMemory).build()
                )
                .build();
    }

}
